package com.fenghongzhang.day003;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main3Activity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        Button button = findViewById(R.id.btn);
        Button button2 = findViewById(R.id.btn2);
        Button button3 = findViewById(R.id.btn3);
//        button.setText(setText);
//        button.setTextColor(button);
//        button.setTextSize();

        //1,方式1,内部类监听器
        MyListener myListener = new MyListener();
        button.setOnClickListener(myListener);

        //2,匿名内部类
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(Main3Activity.this, "btn2", Toast.LENGTH_SHORT).show();
            }
        });

        //3.本类绑定
        button3.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Toast.makeText(this, "本类实现接口", Toast.LENGTH_SHORT).show();
    }

    public void toast(View view) {
        Toast.makeText(this, "属性", Toast.LENGTH_SHORT).show();
    }


    class MyListener implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            //在桌面上段时间内显示一段文字.
//            Toast.makeText(Main3Activity.this, "1231231231", Toast.LENGTH_SHORT).show();
            Toast.makeText(Main3Activity.this, "adfad", Toast.LENGTH_SHORT).show();
        }
    }
}
